<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>设置手势密码</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/index.css" />
	</head>
	<style>
		.mui-table-view {
			margin-top: 50px;
		}
		
		html,
		body {
			width: 100%;
			height: 100%;
			margin: 0px;
			padding: 0px;
			overflow: hidden;
			background-color: #fff;
		}
		
		#holder {
			width: 300px;
			height: 300px;
			/*border: solid 1px #bbb;*/
			border-radius: 5px;
			margin: 50px auto;
			background-color: #fff;
		}
		
		#alert {
			text-align: center;
			padding: 20px 10px;
		}
		
		.mui-popup-input{
			display: none;
		}
		.mui-content {
		    background-color: #fff;
		    -webkit-overflow-scrolling: touch;
		}
	</style>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">解锁</h1>
		</header>
		<div class="mui-content">
			<div id='holder' class="mui-locker" data-locker-options='{"ringColor":"rgba(210,210,210,1)","fillColor":"#ffffff","pointColor":"rgba(0,136,204,1)","lineColor":"rgba(0,136,204,1)"}' data-locker-width='300' data-locker-height='300'></div>
			<div id='alert'></div>
		</div>

		<script type="text/javascript" src="../../js/mui.min.js"></script>
		<script type="text/javascript" src="../../js/vue2.5.js"></script>
		<script type="text/javascript" src="../../js/jquery-3.2.1.min.js"></script>
		<script type="text/javascript" src="../../js/mui.locker.js"></script>
		<script type="text/javascript">
			mui.init();
			(function($, doc) {
				$.init();
				var holder = doc.querySelector('#holder'),
					alert = doc.querySelector('#alert'),
					record = [];
				//处理事件
				holder.addEventListener('done', function(event) {
					var rs = event.detail;
					if(rs.points.length < 4) {
						alert.innerText = '手势密码错误';
						record = [];
						rs.sender.clear();
						return;
					}else{
						alert.innerText = '解锁成功';
						rs.sender.clear();
					}
					console.log(rs.points.join(''));
					record.push(rs.points.join(''));
//					if(record.length >= 2) {
//						if(record[0] == record[1]) {
//							alert.innerText = '手势设定完成';
//						} else {
//							alert.innerText = '两次手势设定不一致';
//						}
//						rs.sender.clear();
//						record = [];
//					} else {
//						alert.innerText = '请确认手势设定';
//						rs.sender.clear();
//					}
				});
			}(mui, document));

			document.getElementById("promptBtn").addEventListener('tap', function(e) {
				e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了 
				var btnArray = ['取消', '确定'];
				mui.prompt('<input type="text" id="username" placeholder="用户名"/><br/><input type="text" id="userpwd" placeholder="密码"/>', '', '重置手势验证', btnArray, function(e) {
					if(e.index == 1) {
						var username=$('#username').val();
						mui.toast(username);
					} else {
						mui.toast('你取消了点击');
					}
				})
			});
		</script>
	</body>

</html>